<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript" src="/${initParam.context_root }/jquery-1.7.2.min.js" ></script>
<script type="text/javascript">

	function registerbtnOnClick(){
		if($("#productName").val()==""){
			alert("상품명을 입력하세요");
			$("#productName").focus();
			return false;
		}else if($("#originalPrice").val()==""){
			alert("원래가격을 입력하세요");
			$("#originalPrice").focus();
			return false;
		}else if($("#reducedPrice").val()==""){
			alert("할인된가격을 입력하세요");
			$("#reducedPrice").focus();
			return false;
		}else if($("#stockEA").val()==""){
			alert("판매량을 입력하세요");
			$("#stockEA").focus();
			return false;
		}else if($("#companyName").val()==""){
			alert("업체명을 입력하세요");
			$("#companyName").focus();
			return false;
		}else if($("#useStartDate").val()==""){
			alert("쿠폰사용시작일을 입력하세요");
			$("#useStartDate").focus();
			return false;
		}else if($("#useEndDate").val()==""){
			alert("쿠폰사용만료일을 입력하세요");
			$("#useEndDate").focus();
			return false;
		}else if($("#saleLocation").val()=="default"){
			alert("판매지역을 선택하세요");
			return false;
		}else if($("#category").val()==""){
			alert("카테고리(제품분류)를 입력하세요");
			$("#category").focus();
			return false;
		}else if($("#productDetail").val()==""){
			alert("제품상세정보를 입력하세요");
			$("#productDetail").focus();
			return false;
		}else if($("#category").val()=="default"){
			alert("카테고리를 선택하세요");
			return false;
		}
		return;
	}
</script>
<form action="/${initParam.context_root }/product_modify.do" method="post" enctype="multipart/form-data">
<input type="hidden" name="productId" value="${requestScope.list.pdto.productId }">
<table>
	<tr>
		<td align="left">상품명</td>
		<td><input type="text" id="productName" name="productName" value="${requestScope.list.pdto.productName }"></td>
	</tr>
	<tr>
		<td>카테고리(분류)</td>
		<td>
		<select id="category" name="productCategory">
			<option value="${requestScope.list.pdto.productCategory }">${requestScope.list.pdto.productCategory }</option>
			<c:forEach items="${requestScope.list.category }" var="cat">
				<option value="${cat }">${cat }</option>
			</c:forEach>
		</select>
		</td>
	</tr>
	<tr>
		<td>원래 가격</td>
		<td><input type="text" id="originalPrice" name="originalPrice" value="${requestScope.list.pdto.originalPrice }"></td>
	</tr>
	<tr>
		<td>할인된 가격</td>
		<td><input type="text" id="reducedPrice" name="reducedPrice" value="${requestScope.list.pdto.reducedPrice }"></td>
	</tr>
	<tr>
		<td>판매량</td>
		<td><input type="text" id="stockEA" name="stockEA" value="${requestScope.list.pdto.stockEA }"></td>
	</tr>
	<tr>
		<td>업체명</td>
		<td>${sessionScope.companyDTO.name }</td>
	</tr>
	<tr>
		<td>쿠폰 사용 시작일</td>
		<td><input type="text" id="useStartDate" name="useStartDate" value="${requestScope.list.pdto.useStartDate }"></td>
	</tr>
	<tr>
		<td>쿠폰 사용 만료일</td>
		<td><input type="text" id="useEndDate" name="useEndDate" value="${requestScope.list.pdto.useEndDate }"></td>
	</tr>
	<tr>
		<td>상품 등록일</td>
		<td>${requestScope.list.pdto.registerDate }</td>
	</tr>
	<tr>
		<td>판매지역</td>
		<td>
			<select id="saleLocation" name="saleLocation">
				<option value="${requestScope.list.pdto.saleLocation }">${requestScope.list.pdto.saleLocation }</option>
				<c:forEach items="${requestScope.list.location }" var="lot">
					<option value="${lot }">${lot }</option>
				</c:forEach>
			</select>
		</td>
	</tr>
	<tr>
		<td>URL<font color="red">(*)</font></td>
		<td><input type="text" id="productURL" name="productURL" value="${requestScope.list.pdto.productURL }"></td>
	</tr>
	<tr>
		<td>상품 이미지<font color="red">(*)</font></td>
		<td>
		<c:choose>
			<c:when test="${not empty requestScope.list.pdto.productImageFilename }">
				<a href="/${initParam.context_root }/deleteProductImage.do?productId=${requestScope.list.pdto.productId}&productImageFilename=${requestScope.list.pdto.productImageFilename}">파일삭제</a>
			</c:when>
			<c:otherwise>
				<input type="file" id="productImage" name="productImage" >
			</c:otherwise>		
		</c:choose>
		</td>
	</tr>
	<tr>
		<td>제품 상세 설명</td>
		<td><textarea id="productDetail" name="content" rows="10" cols="60">${requestScope.list.pdto.content }</textarea></td>
	</tr>
	<tr align="right">
		<td colspan="2"><font size="2" color="blue">※<font color="red">(*)</font>는 선택사항입니다.</font></td>
	</tr>
	<tfoot>
	<tr>
		<td colspan="2"><input type="submit" value="상품등록" onclick="return registerbtnOnClick()"> <input type="reset" value="취소"></td>
	</tr>
	</tfoot>
</table>
</form>
